package com.six.firstpage.config;

import com.google.common.base.Predicates;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.service.VendorExtension;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;

import java.util.ArrayList;

/**
 * @author:zzh
 * @create: 2023-02-27 11:31
 * @Description:
 */
@Configuration
public class SwaggerConfig {
    @Bean
    public Docket docket(){
        Docket docket = new Docket(DocumentationType.SWAGGER_2)
                //组名
                .groupName("Six-caicai")
                //api信息
                .apiInfo(getInfo())
                //选择哪些生成api接口---根据请求路径选择  (2)根据包名选择
                .select()
                //根据请求路径选择
                //.paths(Predicates.and(PathSelectors.regex("/firstpage/api.*")))
                //        (2)根据包名选择
                .apis(RequestHandlerSelectors.basePackage("com.six.firstpage.controller"))
                .build()
                ;

        return docket;
    }

    private ApiInfo getInfo(){
        Contact DEFAULT_CONTACT = new Contact("朱智慧", "http://www.jd.com", "110@qq.com");
        ApiInfo info = new ApiInfo("菜菜帮", "菜菜帮", "2.0", "http://www.baidu.com",
                DEFAULT_CONTACT, "漫动者", "http://www.aaa.com", new ArrayList<VendorExtension>());
        return info;
    }
}
